window.onload=function(){
    layui.use(['jquery','layer'],function(){
        var $ = layui.jquery
        operation = {
            "payMoney":function (data) {
                Utils.layer.closeAll();
                Utils.layer.load(1,{'shade':0.5});
                $.ajax({
                    url: '/withdraw/pay-money',
                    data:data,
                    method:'post',
                    dataType:'json',
                    success:function (data) {
                        Utils.layer.closeAll();
                        Utils.layer.msg(data.msg);
                        location.reload();
                    }
                });
                return true;
            },
            "changeStatus":function (data) {
                Utils.layer.closeAll();
                Utils.layer.load(1,{'shade':0.5});
                $.ajax({
                    url: '/withdraw/change-status',
                    data:data,
                    method:'post',
                    dataType:'json',
                    success:function (data) {
                        Utils.layer.closeAll();
                        Utils.layer.msg(data.msg);
                        location.reload();
                    }
                });
                return true;
            },

        };



        // 通过
        $('.agree').on('click',function(){
            var id = $(this).attr('id');
            var status=$(this).attr('status');
            operation.changeStatus({
               id:id,
               status:status
            });
        });

        // 未通过
        $('.disagree').on('click',function(){
            var id = $(this).attr('id');
            var status=$(this).attr('status');

            Utils.layer.open({
                type: 1,
                title: '提示',
                content: '<div><textarea class="layui-textarea reason"></textarea></div>',
                btn:['确定','取消'],
                btn1:function(){
                    var reason = $('.reason').val();
                    if(reason!=''){
                        operation.changeStatus({
                            id:id,
                            status:status,
                            dismissal:reason

                        });
                    }else{
                        layer.msg('原因不能为空')
                    }
                }
            });
        });

        $('.payMoney').on('click',function () {
            var id = $(this).attr('id');
            operation.payMoney({
                id:id
            });
        })
    })
};